package com.ewayde.common.dto;

/**
 * Response to caller
 *
 * Created Yanwei Li
 */
public class Response extends DTO {

    private static final long serialVersionUID = 1L;
    /**
     * 结果
     */
    private int resultCode;
    private String msg;
    private String timesatmp;

    public boolean isSuccess() {
        return 0 == this.resultCode;
    }

    public void setSuccess() {
        this.resultCode = 0;
    }


    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "Response [resultCode = " + resultCode + ", message=" + msg + "]";
    }

    public static Response buildSuccess() {
        Response response = new Response();
        response.setResultCode(0);
        return response;
    }

    public static Response buildFailure(int resultCode, String message) {
        Response response = new Response();
        response.setResultCode(resultCode);
        response.setMsg(message);
        return response;
    }


}
